package com.zhouyibike.uu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhouyibike.uu.R;
import com.zhouyibike.uu.entity.MyJourneyResult;

import java.util.List;

/**
 * Created by Administrator on 2017/5/1 0001.
 */
public class MyJourneyAdapter extends BaseAdapter {
    private Context context;
    private List<MyJourneyResult.DataBean> list;

    public MyJourneyAdapter(Context context, List<MyJourneyResult.DataBean> list) {
        this.context = context;
        this.list = list;
    }
    public void setList(List<MyJourneyResult.DataBean> list){
        this.list = list;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(context).inflate(R.layout.item_myjourney,null);
        TextView tv_money= (TextView) convertView.findViewById(R.id.tv_myjourney_money);
        TextView tv_time= (TextView) convertView.findViewById(R.id.tv_myjourney_time);
        TextView tv_number= (TextView) convertView.findViewById(R.id.tv_myjourney_number);
        tv_money.setText(list.get(position).getTotalAmount()+"");
        tv_time.setText(list.get(position).getStartTime()+"~"+list.get(position).getEndTime());
        tv_number.setText(list.get(position).getPlateNumber());
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent=new Intent(context, JourneyDetailActivity.class);
//                intent.putExtra("detail",list.get(position));
//                context.startActivity(intent);
            }
        });
        return convertView;
    }
}
